﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL = Auto.Data.BusMan.BLL;
using Model = Auto.Data.BusMan.Model;
using Auto.Components;

namespace Auto.BusMan.AddForm
{
    public partial class fmDriverAddForm : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitPage();
            }
        }

        private void InitPage()
        {
            string driverid = Request.QueryString["DriverID"];
            ucPhraseListBox1.InitControl();
            BindData(driverid);
        }

        private void BindData(string driverid)
        {
            BLL.Drivers bl = new BLL.Drivers();
            Model.Drivers model = bl.GetModel(driverid);

            this.lblDriverName.Text = model.DriverName;
            this.ucDriverPicPicFileShow.FileList = model.DriverPic;// this.lblDriverPic.Text = model.DriverPic;
           // this.lblCompanyID.Text = model.CompanyID;
            this.lblCompanyName.Text = model.CompanyName;
            this.lblSex.Text = model.Sex;
            this.lblBirthDay.Text = model.BirthDay.ToString("yyyy-MM-dd");
            this.lblFamilyAddress.Text = model.FamilyAddress;
            this.lblCellPhone.Text = model.CellPhone;
            this.lblHomePhone.Text = model.HomePhone;
            this.lblIDCardNO.Text = model.IDCardNO;
            this.lblDrivingLicenseType.Text = model.DrivingLicenseType;
            this.ucPhraseListBox1.SelectedValue = model.DrivingLicenseType;
            this.lblDrivingLicenseGetDate.Text = model.DrivingLicenseGetDate.ToString("yyyy-MM-dd");
            this.lblBusIdentificationNO.Text = model.BusIdentificationNO;
            this.lblWorkCompany.InitControl(model.CompanyID,model.WorkCompany);//.Text = model.WorkCompany;
            this.lblWorkType.Text = model.WorkType;
            this.ucIDCardNOPicFileShow.FileList = model.IDCardNOPic;// this.lblIDCardNOPic.Text = model.IDCardNOPic;
            this.ucDrivingLicenseFileShow.FileList = model.DrivingLicense;// this.lblDrivingLicense.Text = model.DrivingLicense;
            //this.lblDrivingPermit.Text = model.DrivingPermit;
            this.ucOperationCertificateFileShow.FileList = model.OperationCertificate;// this.lblOperationCertificate.Text = model.OperationCertificate;
            this.ucSpecialCertificateFileShow.FileList = model.SpecialCertificate;// this.lblSpecialCertificate.Text = model.SpecialCertificate;
            this.ucPoliceStationCertificateFileShow.FileList = model.PoliceStationCertificate;// this.lblPoliceStationCertificate.Text = model.PoliceStationCertificate;
            // this.lblContract.Text = model.Contract;
            this.lblContractDate.Text = StrHelper.GetDateTimeStringValue(model.ContractDate); //model.ContractDate == null ? "" : Convert.ToDateTime(model.ContractDate).ToString("yyyy-MM-dd");
            this.lblContractCycle.Text = model.ContractCycle.ToString();
            this.lblSecurityAgreementDate.Text = StrHelper.GetDateTimeStringValue(model.SecurityAgreementDate);// model.SecurityAgreementDate == null ? "" : Convert.ToDateTime(model.SecurityAgreementDate).ToString("yyyy-MM-dd");
            this.lblSecurityAgreementCycle.Text = model.SecurityAgreementCycle.ToString();
           // this.lblHealthDeclareForm.Text = model.HealthDeclareForm;
           // this.lblHealthDeclareDate.Text = model.HealthDeclareDate.ToString();
          //  this.lblGuarantor.Text = model.Guarantor;

        }

        protected void btnPrintAll_Click(object sender, EventArgs e)
        {
            Response.Redirect("fmDriverAddFormWithPic.aspx?DriverID=" + Request.QueryString["DriverID"]);
        }
    }
}